package com.youku.plugins.commonui.view.noticeCard
{
   import flash.text.TextField;
   import com.youku.baseUI.BasePlayerButton;
   import flash.text.TextFormat;
   import com.youku.utils.AssetUtil;
   import com.youku.plugins.commonui.CommonUIFont;
   import flash.events.MouseEvent;
   import com.youku.plugins.commonui.CommonUIEvent;
   import com.youku.plugins.commonui.CommonUIConstant;
   
   public class NoticeCard extends BaseNoticeCard
   {
      
      public function NoticeCard() {
         super();
      }
      
      protected var _titleText:TextField;
      
      protected var _errorText:TextField;
      
      protected var _confirmButton:BasePlayerButton;
      
      override protected function init() : void {
         super.init();
         this._titleText = new TextField();
         this._titleText.defaultTextFormat = new TextFormat(null,14,3770040);
         this._titleText.text = "提示";
         this._errorText = AssetUtil.getTextField(true);
         this._errorText.defaultTextFormat = CommonUIFont.FONT_NOTICE_TEXT_CENTER;
         this._errorText.text = "";
         this._confirmButton = AssetUtil.getStyleButton("P_Button_OK");
         this._confirmButton.hardOffset = -3;
         this._confirmButton.setStyle("textFormat",CommonUIFont.FONT_NOTICE_BUTTON_SMALL);
         this._confirmButton.label = "确定";
         AssetUtil.autoSizeButton(this._confirmButton);
         _card.addChild(this._errorText);
         _card.addChild(this._confirmButton);
         this._confirmButton.addEventListener(MouseEvent.CLICK,this.onConfirmClick);
         this.updateLayout();
      }
      
      private function onConfirmClick(param1:MouseEvent) : void {
         dispatchEvent(new CommonUIEvent(CommonUIEvent.ERROR_CARD_CONFIRM_CLICK));
      }
      
      override protected function updateLayout() : void {
         super.updateLayout();
         _noticeIcon.y = 60;
         this._errorText.x = 0;
         this._errorText.y = _noticeIcon.y + _noticeIcon.height + 35;
         this._confirmButton.x = (_background.width - this._confirmButton.width) / 2;
         this._confirmButton.y = _noticeIcon.y + _noticeIcon.height + 135;
      }
      
      override public function setSize(param1:Number, param2:Number) : void {
         super.setSize(param1,param2);
         this._errorText.width = CommonUIConstant.NOTICE_CARD_WIDTH;
         this._errorText.height = 80;
         this.updateLayout();
      }
      
      override public function setText(param1:String) : void {
         this._errorText.htmlText = param1;
      }
   }
}
